package com.delayTask.delayQueue;

import com.delayTask.DelayTaskQueue;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *     如果IOC容器中不存在DelayTaskQueue实例Bean,则默认注入一个以JDK的DelayQueue作为底层实现的延迟队列
 * </p>
 * @author 大忽悠
 * @create 2022/9/20 14:19
 */
@Configuration
@ConditionalOnMissingBean(DelayTaskQueue.class)
@Slf4j
public class DelayQueueAutoConfiguration {
    @Bean
    public DelayTaskQueue delayTaskQueue(){
        log.info("jdk原生delayQueue被注入IOC作为默认的延迟队列使用");
        return new DelayQueue();
    }
}
